var macro2;
var macro;
var jsLF = "\n";
var i, retcode, errtext;
var MyDelay = 0;
var MyPosts;

var Aldeias;

var espioes;
var cavalariaLeve;
var command;

i = 0;

espioes = 1;
cavalariaLeve = 7;

var atacado;
var atacante;

var unit_input_spear = 0;
var unit_input_spy = 0;
var unit_input_ram = 0;
var unit_input_knight = 0;
var unit_input_sword = 0;
var unit_input_light = 0;
var unit_input_catapult = 0;
var unit_input_snob = 0;
var unit_input_axe = 0;
var unit_input_marcher = 0;
var unit_input_archer = 0;
var unit_input_heavy = 0;



////001 - 151866");
////002 - 148279");
////003 - 154188");
////004 - 142661");
////005 - 151454");
////006 - 143739");
////007 - 151479");
////008 - 148776");
////009 - 158142");
////010 - 155821");
////011 - 149294");
////012 - 158270");
////013 - 164095");
////014 - 160320");
////015 - 169566");
////016 - 182932");
////017 - 157338");
////018 - 167656");
////019 - 158179");
////020 - 159542");
////021 - 158360");
////022 - 164017");
////023 - 151099");
////024 - 156772");
////025 - 161334");
////026 - 156550");



//atacar










for(var j = 0; j<=3;J++){
    atacante = "167656";
    atacado = "";
    unit_input_axe = 0;
    unit_input_spy = 50;
    unit_input_ram = 1;
    unit_input_catapult = 0;
    atacar();
    zera();
}


atacante = "154188";
atacado = "156095";
unit_input_axe = 0;
unit_input_spy = 200;
unit_input_ram = 0;
unit_input_catapult = 0;
atacar();
zera();


atacante = "154188";
atacado = "161969";
unit_input_axe = 0;
unit_input_spy = 200;
unit_input_ram = 0;
unit_input_catapult = 0;
atacar();
zera();



atacante = "154188";
atacado = "165416";
unit_input_axe = 0;
unit_input_spy = 200;
unit_input_ram = 0;
unit_input_catapult = 0;
atacar();
zera();



atacante = "154188";
atacado = "161334";
unit_input_axe = 0;
unit_input_spy = 200;
unit_input_ram = 0;
unit_input_catapult = 0;
atacar();
zera();



atacante = "154188";
atacado = "156772";
unit_input_axe = 0;
unit_input_spy = 200;
unit_input_ram = 0;
unit_input_catapult = 0;
atacar();
zera();



//001 - 151866 -
//002 - 148279 -
//006 - 143739 -
//007 - 151479 - 156550 - ok 156550 - 156550x3
//009 - 158142 - 158360 - ok - 161334 - 161334x3
//012 - 158270 - 158360  - n - 161334 - 158360x3
//014 - 160320 - 156095 - 164017 - 156095x3
//015 - 169566 - 156095 - 164017 - 164017x3

//
////full
//atacante = "151866";
//atacado = "151099";
//unit_input_axe = 7000;
//unit_input_spy = 200;
//unit_input_ram = 100;
//unit_input_catapult = 250;
//atacar();
//zera();
//
//
//atacante = "151866";
//atacado = "165416"
//unit_input_spy = 100;
//unit_input_ram = 0;
//unit_input_catapult = 1;
//atacar();
//zera();
//
//
//atacante = "148279";
//atacado = "151099";
//unit_input_axe = 7000;
//unit_input_spy = 20;
//unit_input_ram = 100;
//unit_input_catapult = 240;
//atacar();
//zera();
//
//atacante = "148279";
//atacado = "165416";
//unit_input_axe = 80;
//unit_input_spy = 20;
//unit_input_ram = 0;
//unit_input_catapult = 1;
//atacar();
//zera();
//
//atacante = "143739";
//atacado = "156550";
//unit_input_axe = 10000;
//unit_input_spy = 190;
//unit_input_ram = 46;
//unit_input_catapult = 390;
//atacar();
//zera();
//
//atacante = "151479";
//atacado = "156550";
//unit_input_axe = 50;
//unit_input_spy = 0;
//unit_input_ram = 2;
//unit_input_catapult = 2;
//atacar();
//zera();
//
//atacante = "158142";
//atacado = "161334";
//unit_input_axe = 2500;
//unit_input_spy = 95;
//unit_input_ram = 0;
//unit_input_catapult = 1;
//atacar();
//zera();
//
//
//atacante = "158270";
//atacado = "161334";
//unit_input_axe = 0;
//unit_input_spy = 200;
//unit_input_ram = 0;
//unit_input_catapult = 1;
//unit_input_snob = 0;
//atacar();
//zera();
//
//
//atacante = "160320";
//atacado = "156095";
//unit_input_axe = 6300;
//unit_input_spy = 33;
//unit_input_ram = 50;
//unit_input_catapult = 250;
//atacar();
//zera();
//
//atacante = "160320";
//atacado = "164017";
//unit_input_axe = 0;
//unit_input_spy = 100;
//unit_input_ram = 0;
//unit_input_catapult = 1;
//atacar();
//zera();
//
//
//atacante = "169566";
//atacado = "156095";
//unit_input_axe = 3500;
//unit_input_spy = 9;
//unit_input_ram = 33;
//unit_input_catapult = 50;
//atacar();
//zera();
//
//
//
//atacante = "169566";
//atacado = "164017";
//unit_input_axe = 25;
//unit_input_spy = 50;
//unit_input_ram = 0;
//unit_input_catapult = 1;
//atacar();
//zera();
//
//
////fake
//
//
//atacante = "151866";
//atacado = "151099";
//unit_input_spy = 100;
//unit_input_ram = 0;
//unit_input_catapult = 1;
//atacar();
//zera();
//
//atacante = "151866";
//atacado = "151099";
//unit_input_spy = 100;
//unit_input_ram = 0;
//unit_input_catapult = 1;
//atacar();
//zera();
//
//atacante = "151866";
//atacado = "151099";
//unit_input_spy = 100;
//unit_input_ram = 0;
//unit_input_catapult = 1;
//atacar();
//zera();
//
//atacante = "148279";
//atacado = "165416";
//unit_input_axe = 80;
//unit_input_spy = 20;
//unit_input_ram = 0;
//unit_input_catapult = 1;
//atacar();
//zera();
//
//atacante = "148279";
//atacado = "165416";
//unit_input_axe = 80;
//unit_input_spy = 20;
//unit_input_ram = 0;
//unit_input_catapult = 1;
//atacar();
//zera();
//
//atacante = "148279";
//atacado = "165416";
//unit_input_axe = 80;
//unit_input_spy = 20;
//unit_input_ram = 0;
//unit_input_catapult = 1;
//atacar();
//zera();
//
//
//atacante = "158142";
//atacado = "161334";
//unit_input_axe = 0;
//unit_input_spy = 95;
//unit_input_ram = 0;
//unit_input_catapult = 1;
//atacar();
//zera();
//
//
//atacante = "158142";
//atacado = "161334";
//unit_input_axe = 0;
//unit_input_spy = 95;
//unit_input_ram = 0;
//unit_input_catapult = 1;
//atacar();
//zera();
//
//
//atacante = "158142";
//atacado = "161334";
//unit_input_axe = 0;
//unit_input_spy = 95;
//unit_input_ram = 0;
//unit_input_catapult = 1;
//atacar();
//zera();
//
//
//atacante = "160320";
//atacado = "156095";
//unit_input_axe = 0;
//unit_input_spy = 100;
//unit_input_ram = 0;
//unit_input_catapult = 1;
//atacar();
//zera();
//
//
//atacante = "160320";
//atacado = "156095";
//unit_input_axe = 0;
//unit_input_spy = 100;
//unit_input_ram = 0;
//unit_input_catapult = 1;
//atacar();
//zera();
//
//
//atacante = "160320";
//atacado = "156095";
//unit_input_axe = 0;
//unit_input_spy = 100;
//unit_input_ram = 0;
//unit_input_catapult = 1;
//atacar();
//zera();




//
//
//atacante = "1514796";
//atacado = "164017";
//unit_input_axe = 6919;
//unit_input_spy = 50;
//unit_input_ram = 0;
//unit_input_catapult = 1;
//atacar();
//zera();


//nobres


//
//atacante = "143739";
//atacado = "156095";
//unit_input_axe = 10590;
//unit_input_spy = 50;
//unit_input_ram = 46;
//unit_input_catapult = 390;
//unit_input_snob = 0;
//atacar();
//zera();
//
//
//atacante = "143739";
//atacado = "156095";
//unit_input_axe = 0;
//unit_input_spy = 50;
//unit_input_ram = 0;
//unit_input_catapult = 1;
//unit_input_snob = 0;
//atacar();
//zera();
//
//
//atacante = "143739";
//atacado = "156095";
//unit_input_axe = 0;
//unit_input_spy = 50;
//unit_input_ram = 0;
//unit_input_catapult = 1;
//unit_input_snob = 0;
//atacar();
//zera();
//
//
//atacante = "143739";
//atacado = "156095";
//unit_input_axe = 0;
//unit_input_spy = 50;
//unit_input_ram = 0;
//unit_input_catapult = 1;
//unit_input_snob = 0;
//atacar();
//zera();
//
//




function zera(){
    unit_input_spear = 0;
    unit_input_spy = 0;
    unit_input_ram = 0;
    unit_input_knight = 0;
    unit_input_sword = 0;
    unit_input_light = 0;
    unit_input_catapult = 0;
    unit_input_snob = 0;
    unit_input_axe = 0;
    unit_input_marcher = 0;
    unit_input_archer = 0;
    unit_input_heavy = 0;
}



function atacar(){

    macro = "CODE:";
    macro += "URL GOTO=http://br35.tribalwars.com.br/game.php?village="+atacante+"&screen=place&target="+ atacado + jsLF;

    macro += "TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:units ATTR=ID:unit_input_spear CONTENT="+unit_input_spear + jsLF;
    macro += "TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:units ATTR=ID:unit_input_spy CONTENT="+unit_input_spy + jsLF;
    macro += "TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:units ATTR=ID:unit_input_ram CONTENT="+unit_input_ram + jsLF;
    macro += "TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:units ATTR=ID:unit_input_knight CONTENT="+unit_input_knight + jsLF;
    macro += "TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:units ATTR=ID:unit_input_sword CONTENT="+unit_input_sword + jsLF;
    macro += "TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:units ATTR=ID:unit_input_light CONTENT="+unit_input_light + jsLF;
    macro += "TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:units ATTR=ID:unit_input_catapult CONTENT="+unit_input_catapult + jsLF;
    macro += "TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:units ATTR=ID:unit_input_snob CONTENT="+unit_input_snob + jsLF;
    macro += "TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:units ATTR=ID:unit_input_axe CONTENT="+unit_input_axe + jsLF;
    macro += "TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:units ATTR=ID:unit_input_marcher CONTENT="+unit_input_marcher + jsLF;
    macro += "TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:units ATTR=ID:unit_input_archer CONTENT="+unit_input_archer + jsLF;
    macro += "TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:units ATTR=ID:unit_input_heavy CONTENT="+unit_input_heavy + jsLF;
    macro += "TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:units_form ATTR=ID:target_attack" + jsLF;
    macro += "TAG POS=1 TYPE=TD ATTR=ID:inner-border EXTRACT=HTM";

    retcode = iimPlay(macro);
    if (retcode < 0) {              // an error has occured
        errtext = iimGetLastError();
        alert(errtext);
        macro2 = "CODE:";
        macro2 += "WAIT SECONDS=5" + jsLF;
        iimPlay(macro2);
    }

    text = iimGetLastExtract();
    command = text.substr(text.indexOf("action=command&amp;h=")+21,4);

    macro = "CODE:";
    
    if(unit_input_catapult>0)
        macro += "TAG POS=1 TYPE=SELECT FORM=ACTION:/game.php?village="+atacante+"&screen=place&action=command&h="+ command +" ATTR=NAME:building CONTENT=%farm"+ jsLF;
    macro += "TAG POS=1 TYPE=INPUT:SUBMIT FORM=ACTION:http://br35.tribalwars.com.br/game.php?village="+atacante+"&screen=place&action=command&h="+ command +" ATTR=ID:troop_confirm_go" + jsLF;
    macro += "WAIT SECONDS=" + MyDelay + jsLF;
    retcode = iimPlay(macro);
    if (retcode < 0) {              // an error has occured
        errtext = iimGetLastError();
        alert(errtext);
        macro2 = "CODE:";
        macro2 += "WAIT SECONDS=10" + jsLF;
        iimPlay(macro2);
    }


}


